package com.dd.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * Redis条件类，用于根据redis.enabled属性的值决定是否创建Redis相关的Bean
 */
public class RedisCondition implements Condition {

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Environment env = context.getEnvironment();
        // 获取redis.enabled属性的值，默认为false
        return Boolean.parseBoolean(env.getProperty("redis.enabled", "false"));
    }
} 